<template>
  <div class="commend-info" v-if="Object.keys(commends).length != 0">
    <div class="commned-title clearfix">
      <div class="fl">用户评价</div>
      <div class="fr">
        更多
        <img src="@/assets/img/common/back.svg" alt="返回" />
      </div>
    </div>
    <div class="commend-content">
      <div class="comm-user">
        <img :src="commends.user.avatar" alt="avatar" />
        {{commends.user.uname}}
      </div>
      <p class="content">{{commends.content}}</p>
      <p class="atts">
        <span class="atts-time">{{commends.created | getTime}}</span>
        <span class="atts-style">{{commends.style}}</span>
      </p>
      <p class="imgs" v-if="commends.images">
        <img v-for="(item, index) in commends.images" :key="index" :src="item" alt />
      </p>
    </div>
  </div>
</template>

<script>
import { formatDate } from "@/common/utils.js";

export default {
  name: "detail-commend-info",
  props: {
    commends: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  filters: {
    getTime(value) {
      let data = new Date(value * 1000);
      return formatDate(data, "yyyy-MM-dd");
    }
  }
};
</script>

<style scoped>
.commend-info {
  margin-top: 10px;
  padding-bottom: 20px;
  background: #fff;
}
.commned-title {
  padding: 0 12px;
  height: 45px;
  line-height: 45px;
  border-bottom: 1px solid #f2f2f2;
  font-size: 16px;
  color: #333;
}
.commned-title img {
  transform: rotate(180deg);
  vertical-align: -2px;
  width: 15px;
}
.comm-user {
  padding: 15px 10px;
}
.comm-user img {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  vertical-align: -10px;
  margin-right: 5px;
}
.content {
  padding: 0 10px;
  font-size: 14px;
}
.atts {
  padding: 15px 10px;
  font-size: 12px;
  color: #ccc;
}
.atts-time {
  display: inline-block;
  margin-right: 8px;
}
.imgs {
  padding: 0 10px;
  display: flex;
  flex-wrap: wrap;
}
.imgs img {
  width: 32.5%;
  height: 127px;
  margin-right: 0.8%;
}
</style>